import urllib.request

# 访问api接口样例
url = "https://api.apiopen.top/singlePoetry"
res = urllib.request.urlopen(url)
print(res.read().decode('utf-8'))

# 访问网页样例
url = "http://www.baidu.com"
res = urllib.request.urlopen(url)
print(res.read().decode('utf-8'))